﻿using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.Design;
using System.Reflection;
using System.ComponentModel;
using System.Security;
using System.Security.Permissions;

using HttpJson = PickGold.Web.Json;

namespace PickGold.Web.Controls
{
	// <include file='DataPagerDocs.xml' path='DataPagerDoc/Class[@name="PagerDesigner"]/*'/>
	/// <summary>
	/// 
	/// </summary>
	public class Designer : ControlDesigner
	{
		// <include file='DataPagerDocs.xml' path='DataPagerDoc/Method[@name="GetEditableDesignerRegionContent"]/*'/>
		/// <summary>
		/// 
		/// </summary>
		/// <param name="region"></param>
		/// <returns></returns>
		public override string GetEditableDesignerRegionContent(EditableDesignerRegion region)
		{
			region.Selectable = false;
			return null;
		}

		// <include file='DataPagerDocs.xml' path='DataPagerDoc/Method[@name="GetDesignTimeHtml"]/*'/>
		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
		public override string GetDesignTimeHtml()
		{

			var wc = this.Component as Control;
			if (wc == null)
				return null;

			var sw = new StringWriter();
			var tw = new HtmlTextWriter(sw);
			wc.RenderControl(tw);
			return sw.ToString();
		}

		// <include file='DataPagerDocs.xml' path='DataPagerDoc/Method[@name="GetErrorDesignTimeHtml"]/*'/>
		/// <summary>
		/// 
		/// </summary>
		/// <param name="e"></param>
		/// <returns></returns>
		protected override string GetErrorDesignTimeHtml(Exception e)
		{
			var t = "Error creating control：" + Environment.NewLine + e;
			t = t.Replace(Environment.NewLine, "<br />");
			return this.CreatePlaceHolderDesignTimeHtml(t);
		}
	}

	/// <summary>
	/// 
	/// </summary>
	public class Builder : ControlBuilder
	{
		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
		public override bool AllowWhitespaceLiterals()
		{
			return false;
			//return base.AllowWhitespaceLiterals();
		}
	}
}
